import com.alibaba.fastjson.JSON;
import goods.DeliverReq;
import goods.GoodsService;

import java.util.Map;
import java.util.logging.Logger;

public class GoodsCommodityService implements ICommodity
{
	private Logger logger = Logger.getLogger(GoodsCommodityService.class.toString());
	private GoodsService goodsService = new GoodsService();
	private String queryUserName(String uId)
	{
		return("花花");
	}
	private String queryUserPhoneNumber(String uId)
	{
		return("15200101232");
	}
	@Override
	public void sendCommodity(String uId, String commodityId, String bizId, Map<String, String> extMap) throws Exception
	{
		DeliverReq deliverReq = new DeliverReq();
		{
			deliverReq.setUserName(this.queryUserName(uId));
			deliverReq.setUserPhone(this.queryUserPhoneNumber(uId));
			deliverReq.setSku(commodityId);
			deliverReq.setOrderId(bizId);
			deliverReq.setConsigneeUserName(extMap.get("consigneeUserName"));
			deliverReq.setConsigneeUserPhone(extMap.get("consigneeUserPhone"));
			deliverReq.setConsigneeUserAddress(extMap.get("consigneeUserAddress"));
		}
		
		Boolean isSuccess = goodsService.deliverGoods(deliverReq);
		
		logger.info("请求参数[实物商品] => uId：" + uId + "; commodityId：" + commodityId + "; bizId：" + bizId + "; extMap：" + JSON.toJSON(extMap));
		logger.info("测试结果[实物商品]：" + isSuccess);
		
		if (!isSuccess)
			throw new RuntimeException("实物商品发放失败");
	}
}
